package cn.asura.service.impl;

import cn.asura.service.UserService;
import cn.asura.pojo.User;
import cn.asura.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author Asura
 * @description
 * @createTime 2020-09-18 19:30
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserServiceImpl implements UserService {

    private UserMapper userMapper;

    @Autowired
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public User getUserByEmailAndPwd(String email, String pwd) {
        return userMapper.getUserByEmailAndPwd(email, pwd);
    }

    @Override
    public User getUserById(int id) {
        return userMapper.getUserById(id);
    }

    @Override
    public int addUser(Map<String, Object> map) {
        return userMapper.addUser(map);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int updatePwd(int id, String newPwd) {
        return userMapper.updatePwd(id, newPwd);
    }
}
